<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加员工</title>
    <style>
        body {
            background-color: #fff0f5;
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
        }
        .container {
            width: 300px;
            margin: 0 auto;
            background-color: #ffffff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h3 {
            text-align: center;
            color: #ff69b4;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        td {
            padding: 10px;
        }
        input[type="text"],
        select {
            width: calc(100% - 22px);
            padding: 10px;
            margin: 5px 0;
            border: 1px solid #ff69b4;
            border-radius: 5px;
        }
        input[type="button"] {
            background-color: #ff69b4;
            color: white;
            border: none;
            padding: 10px 20px;
            font-size: 16px;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
            display: block;
            margin: 20px auto 0;
        }
        input[type="button"]:hover {
            background-color: #ff85c0;
        }
    </style>
</head>
<body>
<div class="container">
  <h3>emp_add.html</h3>
  <form id="emp_add_form" method="post">
    <table class="emp_table" id="xxx">
      <!--
      <tr>
        <td>员工编号</td>
        <td><input type="text" name="empno" /></td>
      </tr>
      -->
      <tr>
        <td>员工姓名</td>
        <td><input type="text" name="ename" class="easyui-textbox" required data-options="missingMessage:'必须的'"/></td>
      </tr>
      <tr>
        <td>工资</td>
        <td><input type="text" name="sal" class="easyui-textbox"/></td>
      </tr>
      <tr>
        <td>雇佣日期</td>
        <td><input type="text" name="hiredate" class="easyui-datebox"/></td>
      </tr>
      <tr>
        <td>部门</td>
        <td>
          <select name="deptno" class="easyui-combobox" style="width:170px">
            {% for dept in dept_list %}
            <option value="{{dept.deptno}}">{{dept.dname}}</option>
            {% endfor %}
          </select>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <input type="button" class="easyui-linkbutton" style="width:100px;height:30px" value="添加" id="emp_add_btn"/>
        </td>
      </tr>
    </table>
  </form>
</div>
<script type="text/javascript">
  document.getElementById("emp_add_btn").addEventListener("click", function(){
    document.getElementById("emp_add_form").form('submit', {
      url: '{% url 'easyui.emp_add' %}',
      onSubmit: function(){
        var isValid = $(this).form('validate');
        return isValid;
      },
      success: function(data){
        data = JSON.parse(data);
        //alert(data.status);
        closeAddEmpWin();
      }
    });
  });
</script>
</body>
</html>
